
var frontBaseUrl = "http://localhost:5500";
var backBaseUrl = "http://localhost:8080";

window.addEventListener("keypress" ,function(e){
    if(e.code === 'Enter'){
        login();
    }
},false)


function login() {
    let data = $("#login-form").serialize();
    $.ajax({
        url: backBaseUrl + "/login/login",
        data: data,
        method: "POST",
        crossDomain: true,
        xhrFields: { withCredentials: true },

        success: function (r) {
            if (r.code === 0) {
                console.log(r);
                window.location.href = "../index.html";
            } else {
                console.log(r.msg);
                layer.msg(r.msg);
            }
        }, error(error) {
            console.log(error);
            layer.msg(r.msg);
        }
    })
}
function getCaptchaImg() {
    let data = $("#verify-code-img").attr("src", "http://localhost:8080/captcha/captchaImage?" + Math.random());
}